<template>
  <div class="irm-oper-div">
      <ToolBarComponent ref="msgQueryBar" bar-ref-name="msgQueryBar">
        <InputComponent input-name="draftNo" input-lable="报文号"/>
        <InputComponent input-name="msgId" input-lable="报文标识号"/>
        <Button text="查询" :click-function="mockQueryBar"/>
        <Button text="查看报文" :click-function="msgContentQuery"/>
      </ToolBarComponent>
      <GridComponent
          ref="msgLogGrid"
          :auto-load="true"
          key-property-name="id"
          grid-name="msgLogGrid"
          select-moduel="single"
          load-url="draft/queryMsgLog.do"
          max-height-prop="83%"
          :paging-moduel="true"
      >
        <GridColumnComponent width="200px" column-name="报文号" index-name="draftNo"/>
        <GridColumnComponent width="200px" column-name="报文时间" index-name="draftDtTm"/>
        <GridColumnComponent width="350px" column-name="报文标识号" index-name="msgId"/>
        <GridColumnComponent width="350px" column-name="报文原标识号" index-name="orgnlMsgId"/>
      </GridComponent>
    <LongWinComponent ref="msgWin"/>
  </div>
</template>

<script>
import InputComponent from "@/components/input/InputComponent";
import GridComponent from "@/components/grid/GridComponent";
import GridColumnComponent from "@/components/grid/GridColumnComponent";
import ToolBarComponent from "@/components/toolbar/ToolBarComponent";
import Button from "@/components/button/ButtonComponent";
import {postRequest} from "@/axio2";
import LongWinComponent from "@/components/win/LongWinComponent";

export default {
  name: "IrmOper",
  components: {
    LongWinComponent,
    ToolBarComponent, Button,
    GridColumnComponent, GridComponent, InputComponent
  },
  methods: {
    mockQueryBar(){
      let param = this.$refs["msgQueryBar"].getSubmitParams();
      this.$refs["msgLogGrid"].addQueryParams(param);
      this.$refs["msgLogGrid"].load();
    },
    msgContentQuery(){
      let selectKey = this.$refs["msgLogGrid"].getSelectKeys();
      postRequest(
          'draft/queryMsgContent.do',
          {msgLogId:selectKey},
          this.showMsgWin,
          null,
          this
      )
    },
    showMsgWin(response,component){
      let win = component.$refs["msgWin"];
      win.setMessage(response.data.errorMsg);
      win.showWin();
      component.mockQueryBar();
    }
  }
}
</script>

<style scoped>
.irm-oper-div{
  height: 100%;
  overflow: auto;
}
</style>